package com.ricky.base.bean;

import lombok.Data;

/**
 * @author Ricky
 * @date 2020/11/24
 */
@Data
public class ApiResult<T> {
    private boolean success = true;
    private String code = "0";
    private String message = "";
    private T data = null;

    public ApiResult(T data) {
        this.data = data;
    }

    public ApiResult(String message, String code) {
        this.message = message;
        this.code = code;
        this.success = false;
    }

    public static ApiResult<Object> fail(String message) {
        return new ApiResult<>(message, "1001");
    }

    public static <T> ApiResult<T> success(T data) {
        return new ApiResult<>(data);
    }

}
